package com.dl.controller;

import com.dl.pojo.CourseSetup;
import com.dl.service.CourseSetupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class CourseSetupController {

    @Autowired
    private CourseSetupService courseSetupService;

    @RequestMapping("/imit_coursesetup.action")
    public ModelAndView imit_coursesetup(ModelAndView mav){
        List<CourseSetup> courseSetups= courseSetupService.imitCourseSetup();
        if (courseSetups.isEmpty()){
            //failed
            mav.setViewName("fail.jsp");
        }else{
            mav.addObject("courseSetups",courseSetups);
            mav.setViewName("showCoursesetups.jsp");
        }
        return mav;
    }
}
